def
isprime (a):
for
b in
range (2, int (a ** (1 / 2)) + 1)
  :
if a % b == 0
	: 
return False 
 return True 
 digits = { 
"zero": 0, 
"one": 1, 
"two": 2, 
"three": 3, 
"four": 4, 
"five": 5, 
"six": 6, 
"seven": 7, 
"eight": 8, 
"nine":9, 
	  }

n = input ().split (" ") 
 r = "" 
 j = 0 
 k = 0 
 for i
in n:
if i
  in digits:
r = r + str (digits[i]) 
	else
:
print ("Wrong input") 
	  exit () 
 r = int (r) 
 for l in range (r, r * 1000)
  :
if isprime (l)
	:
j = l 
 break 
for z
	in range (r, 2, -1):
if isprime
	  (z):
k = z 
 break 
if r
		-k > j - r:
print (j) 
		  else
		:
print (k)
